/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FolderChunks;

import java.util.ArrayList;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import managerPeer.Node;

/**
 *
 * @author ThienLe
 */
public class ManageFilenameChunk {

    private JList m_ListGUI;
    private ArrayList<InfoChunk> m_ListFilenameChunk;
    private DefaultListModel listModel;

    
    public void updateListPeerOntoGUI(){
        // read list filename chunk from txt
        if(getListModel() == null){
            setListModel(new DefaultListModel());
            this.m_ListGUI.setModel(getListModel());
        }else{
            getListModel().clear();
        }
        for(InfoChunk item : this.getM_ListFilenameChunk()){
            getListModel().addElement(item.getM_FileName()); 
        }
    }
    
    /**
     * @return the m_ListGUI
     */
    public JList getM_ListGUI() {
        return m_ListGUI;
    }

    /**
     * @param m_ListGUI the m_ListGUI to set
     */
    public void setM_ListGUI(JList m_ListGUI) {
        this.m_ListGUI = m_ListGUI;
    }

    /**
     * @return the m_ListFilenameChunk
     */
    public ArrayList<InfoChunk> getM_ListFilenameChunk() {
        return m_ListFilenameChunk;
    }

    /**
     * @param m_ListFilenameChunk the m_ListFilenameChunk to set
     */
    public void setM_ListNode(ArrayList<InfoChunk> m_ListFilenameChunk) {
        this.m_ListFilenameChunk = m_ListFilenameChunk;
    }

    /**
     * @return the listModel
     */
    public DefaultListModel getListModel() {
        return listModel;
    }

    /**
     * @param listModel the listModel to set
     */
    public void setListModel(DefaultListModel listModel) {
        this.listModel = listModel;
    }
}
